#% if bootstrap_bgp.enabled %#
---
# https://docs.cilium.io/en/latest/network/bgp-control-plane/
apiVersion: cilium.io/v2alpha1
kind: CiliumBGPPeeringPolicy
metadata:
  name: l3-policy
spec:
  nodeSelector:
    matchLabels:
      kubernetes.io/os: linux
  virtualRouters:
    - localASN: #{ bootstrap_bgp.local_asn }#
      neighbors:
        #% if bootstrap_bgp.peers %#
        #% for item in bootstrap_bgp.peers %#
        - peerAddress: "#{ item }#/32"
          peerASN: #{ bootstrap_bgp.peer_asn }#
          peerPort: #{ bootstrap_bgp.peer_port | default(179) }#
        #% endfor %#
        #% else %#
        #% if bootstrap_node_default_gateway %#
        - peerAddress: "#{ bootstrap_node_default_gateway }#/32"
        #% else %#
        - peerAddress: "#{ bootstrap_node_network | nthhost(1) }#/32"
        #% endif %#
          peerASN: #{ bootstrap_bgp.peer_asn }#
        #% endif %#
      serviceSelector:
        matchExpressions:
          - {key: somekey, operator: NotIn, values: ['never-used-value']}
---
apiVersion: cilium.io/v2alpha1
kind: CiliumLoadBalancerIPPool
metadata:
  name: l3-pool
spec:
  allowFirstLastIPs: "Yes"
  blocks:
    - cidr: "#{ bootstrap_bgp.advertised_network }#"
#% endif %#
